<!-- 运送模板 -->

<template>
  <div class="RepairList-MyTemplate">
    <MajorTitle title="选择运送模板" />

    <EasyScroll :height="template_selectDict.length > 12 ? 284 : null">
      <div
        v-for="item in template_selectDict"
        :key="item[0]"
        class="RepairList-MyTemplate-item"
        :class="{ 'RepairList-MyTemplate-item-chosen': one.templateId === item[0] }"
        @click="toClick(item)"
      >
        <div class="flexCC">
          <img :src="CORE.image(item[12])" />
        </div>
        <div>{{ item[1] }}</div>
      </div>
    </EasyScroll>
  </div>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'MyTemplate',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [
    CORE.mixWeb('add'),
    CORE.mixSelect('template', 'template_'),
  ],

  /**
   * 本地方法 (轻量重要在前)
   */
  methods: {
    /**
     * 点击
     */
    toClick(item) {
      const { one } = this
      const [
        templateId = '',
        templateName = '',
        orderTypeId = '',
        orderTypeName = '',
        orderTypeCode = '',
        orderSubTypeId = '',
        orderSubTypeName = '',
        orderSubTypeCode = '',
        deliverToolId = '',
        deliverToolName = '',
        deliverToolCode = '',
        description = '',
      ] = one.templateId === item[0] ? [] : item

      const [, organId, uaaUserId, name, phone] = ['', '', '', '', '']

      CORE.merge(one, {
        templateId,
        templateName,
        orderTypeId,
        orderTypeName,
        orderTypeCode,
        orderSubTypeId,
        orderSubTypeName,
        orderSubTypeCode,
        deliverToolId,
        deliverToolName,
        deliverToolCode,
        description,

        resolverUserId: uaaUserId,
        resolverUserName: name,
        resolverUserPhone: phone,
        user: { uaaUserId, name, phone, organId: [organId] }, // 指派人
      })
    },
  },
}
</script>

<style lang="scss">
@import './index.scss';
</style>
